package service;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import dao.CustomerDao;
import dao.EventDao;

@Stateless
//public class CustomerServiceImpl implements CustomerService {
public class CustomerServiceImpl implements CustomerServiceLocal {
//	@EJB
	private CustomerDao customerDao;
//	@EJB
	private EventDao eventDao;
	
	@PostConstruct
	public void init(){
		//代替@EJB注入
		try {
			Context context=new InitialContext();
			customerDao=(CustomerDao) context.lookup("CustomerDaoImpl/local");
			eventDao=(EventDao) context.lookup("EventDaoImpl/local");
			System.out.println("@PostConstruct init()");
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public void createCustomer() {
		customerDao.save();
		eventDao.save();
	}

}
